package com.xiangban.yanglaodajie_admin.controller;

import com.xiangban.yanglaodajie_admin.aop.Permission;
import com.xiangban.yanglaodajie_admin.entity.ClassifyGoods;
import com.xiangban.yanglaodajie_admin.entity.Ids;
import com.xiangban.yanglaodajie_admin.entity.dto.GoodsDto;
import com.xiangban.yanglaodajie_admin.entity.res.ApiResult;
import com.xiangban.yanglaodajie_admin.service.ClassifyGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/6/7 15:15
 */
@RestController
@RequestMapping("/api/admin/classify_goods/")
@Api(tags = "分类维护")
public class ClassifyGoodsController {

    @Autowired
    private ClassifyGoodsService classifyGoodsService;


    @PostMapping("/getClassifyGoodsList")
    @ApiOperation("获取分类列表")
    @Permission(permission = "admin:classify_goods:getClassifyGoodsList")
    public ApiResult<Object> classifyGoodsList(@RequestBody ClassifyGoods classifyGoods){
        return ApiResult.newSuccess(classifyGoodsService.classifyGoodsList(classifyGoods));
    }

    @PostMapping("/addClassifyGoods")
    @ApiOperation("添加分类")
    @Permission(permission = "admin:classify_goods:addClassifyGoods")
    public ApiResult<Object> addClassifyGoods(@RequestBody ClassifyGoods classifyGoods){
        classifyGoodsService.addClassifyGoods(classifyGoods);
        return ApiResult.newSuccess();
    }

    @PostMapping("/updateClassifyGoods")
    @ApiOperation("修改分类")
    @Permission(permission = "admin:classify_goods:updateClassifyGoods")
    public ApiResult<Object> updateClassifyGoods(@RequestBody ClassifyGoods classifyGoods){
        classifyGoodsService.updateClassifyGoods(classifyGoods);
        return ApiResult.newSuccess();
    }

    @PostMapping("/delClassifyGoods")
    @ApiOperation("删除分类")
    @Permission(permission = "admin:classify_goods:delClassifyGoods")
    public ApiResult<Object> delClassifyGoods(@RequestBody Ids ids){
        classifyGoodsService.delClassifyGoods(ids);
        return ApiResult.newSuccess();
    }

    @PostMapping("/ClassifyGoodsInfo")
    @ApiOperation("分类详情")
    @Permission(permission = "admin:classify_goods:ClassifyGoodsInfo")
    public ApiResult<Object> ClassifyGoodsInfo(@RequestBody ClassifyGoods classifyGoods){
        return ApiResult.newSuccess(classifyGoodsService.ClassifyGoodsInfo(classifyGoods));
    }

}
